package sgbag1.Vues;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;

import java.awt.geom.Point2D;

import sgbag1.Noyau.Embranchement;
import sgbag1.Noyau.Guichet;

public class VueEmbranchement extends VueElement {
    
    private int rayon = 5;
    private Color couleur = new Color(50, 50, 50);
    private Embranchement embranchement;
    
    public VueEmbranchement(Embranchement e){
        super(new Point(e.getPosition()));
        embranchement = e;
        this.CalculerBoiteEnglobante();
    }
    
    public Embranchement getObjetNoyau(){
        return embranchement;
    }
    
    @Override
    public void setTauxConversion(double t){
        super.setTauxConversion(t);
        position = new Point(embranchement.getPosition());
        /*position.x *= tauxConversion;
        position.y *= tauxConversion;*/
        position.setLocation(position.getX()*tauxConversion, position.getY()*tauxConversion);

        this.CalculerBoiteEnglobante();
    }
    
    @Override
    public void setDecalage(Point p){
        super.setDecalage(p);
        //position.translate(decalage.getX(), decalage.getY());
        position.setLocation(position.getX()+decalage.getX(), position.getY()+decalage.getY());
        this.CalculerBoiteEnglobante();
    }
    
    @Override
    public void Dessiner(Graphics g){
        Graphics2D g2 = (Graphics2D) g;
        
        g2.setColor(couleur);
        g2.fillOval((int)position.getX() - rayon, (int)position.getY() - rayon, 2 * rayon, 2 * rayon);
        super.Dessiner(g);
    }
    
    @Override
    public void CalculerBoiteEnglobante() {
        boiteEnglobante = new Rectangle((int)position.getX() - rayon, (int)position.getY() - rayon, 2 * rayon, 2 * rayon);
    }
}
